#ifndef __OGLRENDER_H__
#define __OGLRENDER_H__

#include <GL/glew.h>
#include <map>
#include <vector>
#include "types.h"

namespace Hope {

    struct MeshEntity;
    class OGLShaderObject;

	class OGLRender
	{
	public:
        OGLRender();

		~OGLRender();

		static OGLRenderPtr Instance();

        //bool CreateShader(const char *shader, ShaderType type);

        void drawMesh(const MeshPtr &mesh);

        void drawVertexPrimitiveList(const void *vertices, uint32_t vertexCount, const void *indexList, uint32_t primitiveCount);

        const OGLRenderBufferPtrVec & getIndexRenderBufferVec(const MeshPtr &mesh);

        const OGLRenderBufferPtrVec & getVertexRenderBufferVec(const MeshPtr &mesh);

        bool createRenderBuffers(const MeshPtr &mesh);

        void deleteRenderBuffer(OGLRenderBufferPtrVec &buffers);

        bool updateRenderBuffer(OGLRenderBufferPtrVec &buffers, GLenum target, GLuint usage);

	private:

		bool init();

       // bool createVertexShader(const char *shader);

       // bool createFragmentShader(const char *shader);
        bool updateBuffer(OGLRenderBufferPtr &buffer, GLuint usage, uint32_t size, void *data);

	private:
		static OGLRenderPtr s_render;

        std::map<MeshPtr, std::pair<OGLRenderBufferPtrVec, OGLRenderBufferPtrVec>> m_buffMap;

        MeshPtr m_curMeshPtr{};
	};

}

#endif